/**
* @author elbek
 * 8:50:28 PM Feb 20, 2012
 */
package framework.factory;

import framework.BaseManager;
import framework.customer.ICustomer;
import framework.customer.impl.CompanyCustomer;
import framework.customer.impl.PersonalCustomer;

/**
 * Construct the objects based on user request
 * @author Hu Chen
 *
 */
public class CustomerFactory {
	/**
	 * String name, String street, String city,
			String zip, String email,String state, String birthDate
	 * @param vals
	 * vals[0] is customer type it might be P - personal, C - Company, CC - CreditCard 
	 * vals[1] name
	 * vals[2] street
	 * vals[3] city
	 * vals[4] zip
	 * vals[5] email
	 * vals[6] state
	 * vals[7] for P  = birthdate, for C = numberOfEmployees, for CC - is null 
	 * @return ICustomer
	 */
	public static ICustomer createCustomer(Object[] vals){
		if("P".equals(vals[0].toString())){
			return new PersonalCustomer(vals[1].toString(),vals[2].toString(),
					vals[3].toString(),vals[4].toString(),vals[5].toString(),
					vals[6].toString(),vals[7].toString());
		}else if("C".equals(vals[0])){
			return new CompanyCustomer(vals[1].toString(),vals[2].toString(),
					vals[3].toString(),vals[4].toString(),vals[5].toString(),
					vals[7].toString(),Integer.valueOf(vals[7].toString()));
		}else if("CC".equals(vals[0])){
			return new PersonalCustomer(vals[1].toString(),vals[2].toString(),
					vals[3].toString(),vals[4].toString(),vals[5].toString(),
					vals[6].toString(),null);
		}
		return null;
	}

}
